<template>
  <div>
    <el-form :inline="true">
      <el-form-item label="关键字">
        <el-input v-model="searchParams.key" placeholder="搜索关键字" />
      </el-form-item>
      <el-form-item label="日期">
        <el-date-picker
            v-model="timeRange"
            type="daterange"
            value-format="YYYY-MM-DD"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
          />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSearch">搜索</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      timeRange: [],
      searchParams: {
        key: '', // 搜索关键字
        start: '', // 开始日期
        end: '' // 结束日期
      }
    }
  },
  methods: {
    onSearch () {
      this.searchParams.start = this.timeRange[0]
      this.searchParams.end = this.timeRange[1]
      this.$emit('onSearch', this.searchParams)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
